<template>
    <div>
        <el-form :model="formData" ref="formRef" label-width="80px">
            
            <el-form-item label="用户名">
                <el-input v-model="formData.username"></el-input>
            </el-form-item>
            
            <el-form-item label="密码">
                <el-input v-model="formData.password"></el-input>
            </el-form-item>
            
            <el-form-item>
                <el-button @click="submitForm">提交</el-button>
            </el-form-item>
        </el-form>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                formData: {},
                formRef: null
            };
        },
        methods: {
            submitForm() {
                this.$refs.formRef.validate((valid) => {
                    if (valid) {
                        console.log('表单提交成功', this.formData);
                    } else {
                        console.log('表单验证失败');
                        return false;
                    }
                });
            }
        }
    };
</script>

<style scoped>
    /* 可添加自定义样式 */
</style>